package com.mxpio.erp.equipment.controller;


import com.mxpio.erp.common.equipment.service.EquipmentReportService;
import com.mxpioframework.common.vo.Result;
import com.mxpioframework.jpa.query.Criteria;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@Tag(name = "EquipmentUpkeepWorkOrderController}", description = "维系人员首页_当月维保工单")
@RestController
@RequestMapping("/erp/equipment/upkeep/work/order/")
public class EquipmentUpkeepWorkOrderController {

    @Autowired
    private EquipmentReportService equipmentReportService;

/*=====================================================当月维修==========================================================*/

    @GetMapping("maintenance/assemble")
    @Operation(summary = "当月维修单数", description = "当月维修单数", method = "GET")
    public Result<Integer> assemble(@Parameter(description="查询参数") Criteria criteria) throws Exception {
        Integer assemble = equipmentReportService.getAssemble();
        return Result.OK(assemble);
    }

    @GetMapping("maintenance/allocation")
    @Operation(summary = "当月待分配单数", description = "当月待分配单数", method = "GET")
    public Result<Integer> allocation(@Parameter(description="查询参数") Criteria criteria) throws Exception {
        Integer allocation = equipmentReportService.getAllocation();
        return Result.OK(allocation);
    }

    @GetMapping("maintenance/toBeRepaired")
    @Operation(summary = "当月待维修单数", description = "当月待维修单数", method = "GET")
    public Result<Integer> toBeRepaired(@Parameter(description="查询参数") Criteria criteria) throws Exception {
        Integer toBeRepaired = equipmentReportService.getToBeRepaired();
        return Result.OK(toBeRepaired);
    }

    @GetMapping("maintenance/inMaintenance")
    @Operation(summary = "当月维修中单数", description = "当月维修中单数", method = "GET")
    public Result<Integer> inMaintenance(@Parameter(description="查询参数") Criteria criteria) throws Exception {
        Integer inMaintenance = equipmentReportService.getInMaintenance();
        return Result.OK(inMaintenance);
    }

    @GetMapping("maintenance/spareParts")
    @Operation(summary = "当月等备件单数", description = "当月等备件单数", method = "GET")
    public Result<Integer> spareParts(@Parameter(description="查询参数") Criteria criteria) throws Exception {
        Integer spareParts = equipmentReportService.getSpareParts();
        return Result.OK(spareParts);
    }

    @GetMapping("maintenance/outsourcing")
    @Operation(summary = "当月委外中单数", description = "当月委外中单数", method = "GET")
    public Result<Integer> outsourcing(@Parameter(description="查询参数") Criteria criteria) throws Exception {
        Integer outsourcing = equipmentReportService.getOutsourcing();
        return Result.OK(outsourcing);
    }

    @GetMapping("maintenance/toBeSubmitted")
    @Operation(summary = "当月待提交单数", description = "当月待提交单数", method = "GET")
    public Result<Integer> toBeSubmitted(@Parameter(description="查询参数") Criteria criteria) throws Exception {
        Integer toBeSubmitted = equipmentReportService.getToBeSubmitted();
        return Result.OK(toBeSubmitted);
    }

    @GetMapping("maintenance/toBeAccepted")
    @Operation(summary = "当月待验收单数", description = "当月待验收单数", method = "GET")
    public Result<Integer> toBeAccepted(@Parameter(description="查询参数") Criteria criteria) throws Exception {
        Integer toBeAccepted = equipmentReportService.getToBeAccepted();
        return Result.OK(toBeAccepted);
    }

    @GetMapping("maintenance/toBeEvaluated")
    @Operation(summary = "当月待评价单数", description = "当月待评价单数", method = "GET")
    public Result<Integer> toBeEvaluated(@Parameter(description="查询参数") Criteria criteria) throws Exception {
        Integer toBeEvaluated = equipmentReportService.getToBeEvaluated();
        return Result.OK(toBeEvaluated);
    }

/*=====================================================当月保养==========================================================*/

    @GetMapping("orderStatusAssemble")
    @Operation(summary = "当月保养工单明细", description = "当月保养工单明细", method = "GET")
    public Result<Integer> orderStatusAssemble(@Parameter(description="查询参数") Criteria criteria) throws Exception {
        Integer orderStatusAssemble = equipmentReportService.getOrderStatusAssemble();
        return Result.OK(orderStatusAssemble);
    }

    @GetMapping("orderStatusAllocation")
    @Operation(summary = "当月待分配单数", description = "当月待分配单数", method = "GET")
    public Result<Integer> orderStatusAllocation(@Parameter(description="查询参数") Criteria criteria) throws Exception {
        Integer orderStatusAllocation = equipmentReportService.getOrderStatusAllocation();
        return Result.OK(orderStatusAllocation);
    }

    @GetMapping("orderStatusMaintenance")
    @Operation(summary = "当月待维修单数", description = "当月待维修单数", method = "GET")
    public Result<Integer> orderStatusMaintenance(@Parameter(description="查询参数") Criteria criteria) throws Exception {
        Integer orderStatusMaintenance = equipmentReportService.getOrderStatusMaintenance();
        return Result.OK(orderStatusMaintenance);
    }

    @GetMapping("orderStatusUnderMaintenance")
    @Operation(summary = "当月维保中单数", description = "当月维保中单数", method = "GET")
    public Result<Integer> orderStatusUnderMaintenance(@Parameter(description="查询参数") Criteria criteria) throws Exception {
        Integer orderStatusUnderMaintenance = equipmentReportService.getOrderStatusUnderMaintenance();
        return Result.OK(orderStatusUnderMaintenance);
    }

    @GetMapping("orderStatusSpareParts")
    @Operation(summary = "当月等备件单数", description = "当月等备件单数", method = "GET")
    public Result<Integer> orderStatusSpareParts(@Parameter(description="查询参数") Criteria criteria) throws Exception {
        Integer orderStatusSpareParts = equipmentReportService.getOrderStatusSpareParts();
        return Result.OK(orderStatusSpareParts);
    }

    @GetMapping("orderStatusShelve")
    @Operation(summary = "当月搁置中单数", description = "当月搁置中单数", method = "GET")
    public Result<Integer> orderStatusShelve(@Parameter(description="查询参数") Criteria criteria) throws Exception {
        Integer orderStatusShelve = equipmentReportService.getOrderStatusShelve();
        return Result.OK(orderStatusShelve);
    }

    @GetMapping("orderStatusToBeSubmitted")
    @Operation(summary = "当月待提交单数", description = "当月待提交单数", method = "GET")
    public Result<Integer> orderStatusToBeSubmitted(@Parameter(description="查询参数") Criteria criteria) throws Exception {
        Integer orderStatusToBeSubmitted = equipmentReportService.getOrderStatusToBeSubmitted();
        return Result.OK(orderStatusToBeSubmitted);
    }

    @GetMapping("orderStatusToBeAccepted")
    @Operation(summary = "当月待验收单数", description = "当月待验收单数", method = "GET")
    public Result<Integer> orderStatusToBeAccepted(@Parameter(description="查询参数") Criteria criteria) throws Exception {
        Integer orderStatusToBeAccepted = equipmentReportService.getOrderStatusToBeAccepted();
        return Result.OK(orderStatusToBeAccepted);
    }

    @GetMapping("orderStatusToBeEvaluate")
    @Operation(summary = "当月待评价单数", description = "当月待评价单数", method = "GET")
    public Result<Integer> orderStatusToBeEvaluate(@Parameter(description="查询参数") Criteria criteria) throws Exception {
        Integer orderStatusToBeEvaluate = equipmentReportService.getOrderStatusToBeEvaluate();
        return Result.OK(orderStatusToBeEvaluate);
    }

/*===================================================维修/保养工单明细=========================================================*/

    // 保养
    @GetMapping("repairDetails")
    @Operation(summary = "当月保养工单明细", description = "当月保养工单明细", method = "GET")
    public Result<Map<String, Integer>> maintenanceDetails(@Parameter(description="查询参数") Criteria criteria) {
        Map<String, Integer> maintenanceDetails = equipmentReportService.getMaintenanceDetails();
        return Result.OK(maintenanceDetails);
    }

    // 维修
    @GetMapping("maintenanceDetails")
    @Operation(summary = "当月维修工单明细", description = "当月维修工单明细", method = "GET")
    public Result<Map<String, Integer>> repairDetails(@Parameter(description="查询参数") Criteria criteria) {
        Map<String, Integer> repairDetails = equipmentReportService.getRepairDetails();
        return Result.OK(repairDetails);
    }
}
